
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
 */
package itm.bo.administracion;

//~--- non-JDK imports --------------------------------------------------------

import itm.conexion.SQLServerConection;

import itm.dao.administracion.TipoAtributoDAO;

import itm.exception.ControlException;

import itm.vo.administracion.TipoAtributoVO;

//~--- JDK imports ------------------------------------------------------------

import java.sql.Connection;
import java.sql.SQLException;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author BISA20
 */
public class TipoAtributoBO {
    String             temp     = "";
    SQLServerConection conexion = new SQLServerConection();
    Connection         dbConexion;
    TipoAtributoDAO    tipoAtributoDAO;

    public String crearTipoAtributo(TipoAtributoVO tipoAtributoVO) throws ControlException {
        String temp = "";

        try {
            dbConexion      = conexion.openConnection();
            tipoAtributoDAO = new TipoAtributoDAO(dbConexion);
            temp            = tipoAtributoDAO.crearTipoAtributo(tipoAtributoVO);
        } catch (SQLException ce) {
            ce.printStackTrace();
        } finally {
            conexion.closeConnection(dbConexion);
        }

        return temp;
    }

    public List<TipoAtributoVO> consultarTipoAtributo(TipoAtributoVO tipoAtributoVO) throws ControlException {
        List<TipoAtributoVO> listaTipoAtributo = new ArrayList<TipoAtributoVO>();

        try {
            dbConexion        = conexion.openConnection();
            tipoAtributoDAO   = new TipoAtributoDAO(dbConexion);
            listaTipoAtributo = tipoAtributoDAO.consultarTipoAtributo(tipoAtributoVO);
        } catch (SQLException ex) {
            ex.getStackTrace();
        } finally {
            conexion.closeConnection(dbConexion);
        }

        return listaTipoAtributo;
    }

    public String eliminarTipoAtributo(TipoAtributoVO tipoAtributoVO) throws ControlException {
        String temp = "";

        try {
            dbConexion      = conexion.openConnection();
            tipoAtributoDAO = new TipoAtributoDAO(dbConexion);
            temp            = tipoAtributoDAO.eliminarTipoAtributo(tipoAtributoVO);
        } catch (SQLException ce) {
            ce.printStackTrace();
        } finally {
            conexion.closeConnection(dbConexion);
        }

        return temp;
    }

    public String actualizarTipoAtributo(TipoAtributoVO tipoAtributoVO) throws ControlException {
        try {
            dbConexion      = conexion.openConnection();
            tipoAtributoDAO = new TipoAtributoDAO(dbConexion);
            temp            = tipoAtributoDAO.actualizarTipoAtributo(tipoAtributoVO);
        } catch (SQLException ce) {
            ce.printStackTrace();
        } finally {
            conexion.closeConnection(dbConexion);
        }

        return temp;
    }

    public List<TipoAtributoVO> listarTipoAtributo() throws Exception {
        List<TipoAtributoVO> listaTipoAtributo = new ArrayList<TipoAtributoVO>();

        try {
            dbConexion        = conexion.openConnection();
            tipoAtributoDAO   = new TipoAtributoDAO(dbConexion);
            listaTipoAtributo = tipoAtributoDAO.listarTipoatributo();
        } catch (Exception e) {
            e.getStackTrace();
        } finally {
            conexion.closeConnection(dbConexion);
        }

        return listaTipoAtributo;
    }
}
